#
# perc2 - calculation of the fractal dimension of correlated
# bond percolation cluster hulls
#
# Copyright (C) 2009, 2010 Indrek Mandre <indrek(at)mare.ee>
# http://www.mare.ee/indrek/perc2/, http://code.google.com/p/perc2/
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# 

import sys, math

path = sys.argv[1]

data = {}

MUL=25.0

total=0

f = open (sys.argv[1], 'r')
for line in f:
  (x, y) = line.strip().split (' ')
  x = int(math.floor(math.log(float(x))*MUL))
  y = int(y)
  if data.has_key(x):
      data[x] += y
  else:
      data[x] = y
  total += y

out = []
keys = data.keys()
keys.sort()
m = 0
for k in range(keys[0],keys[-1]+1):
  if data.has_key(k):
    v = data[k]
  else:
    v = 0
  f = int(math.floor(math.exp(float(k)/MUL)))
  s = int(math.floor(math.exp(float(k + 1)/MUL)))
  out.append([float(f+s)/2.0, float(v) / total / (s - f)])
  m = max(m, out[-1][1])

for (x,v) in out:
  print "%g %g" % (x, v)

